package com.bluesky.jwf.example1.forms;

import com.bluesky.javawebbrowser.domain.html.tags.Tag;
import com.bluesky.jwf.component.list.ListItem;
import com.bluesky.jwf.example1.domain.Person;

public class PeopleListItem extends ListItem {
	private Tag numberTag;
	private Tag nameTag;
	private Tag birthDateTag;
	private Tag emailTag;

	@Override
	public void init(String html) {

		super.init(html);

		numberTag = loadByJwfClass("number");
		nameTag = loadByJwfClass("name");
		birthDateTag = loadByJwfClass("birthDate");
		emailTag = loadByJwfClass("email");
	}

	@Override
	public void setModel(Object model) {
		super.setModel(model);

		Person p = (Person) model;

		numberTag.setBodyAndParse(String.valueOf(getIndex()+1));
		
		nameTag.setBody(p.getName());
		nameTag.parseBody();
		birthDateTag.setBody(p.getBirthDate().toString());
		birthDateTag.parseBody();
		emailTag.setBody(p.getEmail());
		emailTag.parseBody();
	}
}